# -*- mode: org; fill-column: 80; -*-
#+TITLE: Record Video
#+AUTHOR: Zelphir Kaltstahl
#+STARTUP: content indent align inlineimages entitiesplain nologdone nologreschedule nologredeadline nologrefile
#+TODO: TODO WIP | DONE
#+DATE: [2021-11-02 Tue]
#+LANGUAGE: English
#+PRIORITIES: A C C
#+KEYWORDS: ssh debug guide troubleshoot

* Record video
:PROPERTIES:
:CUSTOM_ID: record-video
:END:

To record a video of 1280x1040 resolution starting from the coordinates 0 (horizontal) and 40 (vertical) from the top left corner of the screen run the following command:

#+NAME: record-video
#+begin_src shell
ffmpeg \
    -video_size 1280x1040 \
    -framerate 60 \
    -f x11grab \
    -i ${DISPLAY}+0,40 \
    -codec:v libx264 \
    -crf 16 \
    -preset slower \
    ~/Videos/screen-recording.mp4
#+end_src

** Explanation
:PROPERTIES:
:CUSTOM_ID: record-video-explanation
:END:

~-videosize~ sets the width and height of the area, which is captured by FFMPEG.

~-framerate~ sets the number of frames, which FFMPEG shall try to capture during every second.

~-f x11grab~ tells FFMPEG to grab frames from the X11 display server as input data.

~-i ${DISPLAY}+0,40~ tells FFMPEG which display to capture and tells it to capture an area, which starts at =0= (horizontal), =40= (vertical).

~-codec:v libx264~ tells FFMPEG to encode only a video stream (=:v=) and use =libx264= for encoding.

~-crf~ tells FFMPEG what the quality of the video should be. Lower means better quality. Default for x264 encoder is =23=. Default for x265 encoder is =28=.

~-preset~ tells FFMPEG how much time to spend on compressing frames. Possible values are:

+ ultrafast
+ superfast
+ veryfast
+ faster
+ fast
+ medium
+ slow
+ slower
+ veryslow
+ placebo
